<?
/*导览页面，按照分类分别列出不同的数据*/
/*调用的时候传递景点的nid即可，获取所有导览的子分类，用来区分?term_nid=xxxxx即可**/
/*输出二位数组参考*/

include_once("base.php");

$_place_term_nid=$_REQUEST['nid'];
//$_place_term_nid=26;
////通过relation筛选所有的子分类
//$_daolan_terms=select_lines_items($table_prefix."term","listorder desc","nid,name,term_banner","term1 = '".$_place_term_nid."' ","");
//
//print_r2($_daolan_terms);
//echo "$_daolan_terms<br/><br/>";


//循环获取子分类内的文章。
//关系表获取所有的nid，
//之后再筛选所有nid的内容
//foreach($_daolan_terms as $k=>$v)
//{

//relation获取所有文章nid
$_relation_list=select_lines_items($table_prefix."relation","nid desc","detail_nid","term_nid = '".$_place_term_nid."' ","");
//   print_r2($_relation_list);
//    foreach($_relation_list as $v){
$list = [];
for($i=0;$i<count($_relation_list);$i++){
    $nid = $_relation_list[$i][detail_nid];
    $daolan_detail_list=select_lines_all_items($table_prefix."detail","nid desc","nid = '".$nid."' ","");
    $list + $daolan_detail_list;
    $list = array_merge_recursive($list,$daolan_detail_list);
};
//       $nid = $_relation_list[0][detail_nid];
//        $daolan_detail_list=select_lines_items($table_prefix."detail","listorder desc,nid desc","name,clickrate,nid,icon","nid = '".$nid."' ","");
//$daolan_detail_list=select_lines_all_items($table_prefix."detail","nid desc","nid = '".$nid."' ","");
//print_r2($list);
//        echo $list;
//    };
//    echo $_relation_list[0][detail_nid];
//    $_relation_list_1array=transform_2dar ray_in_1darray_number_as_key($_relation_list,"detail_nid");
//    print_r2($_relation_list_1array);
    //print_r2($_relation_list);
//    $_relation_list_str=implode("','",$_relation_list_1array);

//    $daolan_detail_list=select_lines_items($table_prefix."detail","listorder desc,nid desc","name,clickrate,nid,icon","nid = 3704 ","");

//    print_r2($daolan_detail_list);
    #$v['detail']=$daolan_detail_list;

    #$result

//}
//print_r2($daolan_detail_list);
//echo "daolan_detail_list<br/><br/>";

//有了分类列表，文章所属列表，开始循环拼装二w数组

//for($i=0;$i<count($_daolan_terms);$i++)
//{
//    $_result[$i]['term_nid']  = $_daolan_terms[$i]['nid'];
//    $_result[$i]['term_name']       = $_daolan_terms[$i]['name'];
//    $_result[$i]['term_banner']       = $_daolan_terms[$i]['term_banner'];
//    $_result[$i]['list']      = $daolan_detail_list[$_daolan_terms[$i]['nid']];
//}



$result=$list;

echo out("success",0,$result);
?>